home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / laptop-mode < prev    next >
Text File  |  2008-10-24  |  2KB  |  86 lines

  1. #! /bin/sh
  2. #
  3. # chkconfig: - 90 90
  4. # description: Starts and stops "laptop-mode" - tweaks system behavior
  5. #              to extend battery life.
  6. #
  7. # config:  /etc/laptop-mode/laptop-mode.conf
  8.  
  9. ### BEGIN INIT INFO
  10. # Provides:          laptop-mode
  11. # Should-Start:      $all
  12. # Required-Start:    $remote_fs
  13. # Required-Stop:     $remote_fs
  14. # Default-Start:     2 3 4 5
  15. # Default-Stop:      0 1 6
  16. # Short-Description: Enable laptop-mode-tools power management functions
  17. # Description:       Enable laptop-mode-tools power management functions
  18. ### END INIT INFO
  19.  
  20.  
  21. test -f /usr/sbin/laptop_mode || exit 0
  22.  
  23. . /lib/lsb/init-functions
  24.  
  25. # Check that laptop-mode is enabled
  26. if [ -f /etc/default/laptop-mode ]; then
  27.     . /etc/default/laptop-mode;
  28. fi
  29.  
  30. # FIXME: this shouldn't be configured there
  31. if [ -f /etc/default/acpi-support ]; then
  32.     . /etc/default/acpi-support;
  33. fi
  34.  
  35. if [ x$ENABLE_LAPTOP_MODE = xfalse ]; then
  36.     exit 0;
  37. fi
  38.  
  39. # Enable laptop mode when the system is booted when running on battery.
  40.  
  41. case $1 in
  42.   start)
  43.     log_action_begin_msg "Enabling laptop mode"
  44.     mkdir -p /var/run/laptop-mode-tools
  45.     touch /var/run/laptop-mode-tools/enabled
  46.     RESULT=`/usr/sbin/laptop_mode init auto`
  47.     log_action_end_msg $? "$RESULT"
  48.     ;;
  49.  
  50.   restart|reload|force-reload)
  51.     # Full restart: first stop laptop mode completely (to restore default mount options etc.)
  52.     log_action_begin_msg "Disabling laptop mode"
  53.     mkdir -p /var/run/laptop-mode-tools
  54.     rm -f /var/run/laptop-mode-tools/enabled
  55.     RESULT=`/usr/sbin/laptop_mode init stop`
  56.     log_action_end_msg $? "$RESULT"
  57.  
  58.     # Now remove files containing stored status, re-enable, and start it up again.
  59.     log_action_begin_msg "Enabling laptop mode"
  60.     rm -f /var/run/laptop-mode-tools/*
  61.     touch /var/run/laptop-mode-tools/enabled
  62.     RESULT=`/usr/sbin/laptop_mode init auto force`
  63.     log_action_end_msg $? "$RESULT"
  64.     ;;
  65.  
  66.   stop)
  67.     log_action_begin_msg "Disabling laptop mode"
  68.     rm -f /var/run/laptop-mode-tools/enabled
  69.     RESULT=`/usr/sbin/laptop_mode init stop`
  70.     log_action_end_msg $? "$RESULT"
  71.     ;;
  72.  
  73.   status)
  74.     echo "Laptop mode status:"
  75.     echo
  76.     /usr/sbin/laptop_mode status
  77.     ;;
  78.     
  79.   *)
  80.     echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
  81.     exit 2
  82.     ;;
  83. esac
  84.  
  85. exit 0
  86.